
<?php

if (is_string($_GET["title"])) {
	$title = $_GET["title"];
}

if (is_string($_GET["content"])) {
	$content = $_GET["content"];
}

$personid = (int)$_GET["personid"];
if ($personid > 0) {
	$personid = $_GET["personid"];
} else {
	// 不填用户id不往下走
	exit("请先填写正确的用户personid!");
}


$host = 'localhost';
$root = 'root';
$pwd = 'root';
$form = 'mymessageboard';	// mes

$con = mysqli_connect($host, $root, $pwd);
if ($con) {
	echo "数据库连接成功<br>";
} else {
	echo "数据库连接失败" . "<br>";
}

$ret = mysqli_select_db($con, $form);
if ($ret) {
	echo "成功连接数据库: $form <br>";
} else {
	echo "连接该数据库失败: $form" . mysqli_error() . "<br>";
}

// 插入表
$sql = "insert into Messages (title, content, personid) values ('" . $title . "', '" . $content . "', " . $personid . ")";
echo "sql = $sql<br>";
$ret = mysqli_query($con, $sql);
if ($ret) {
	echo "文章写入成功<br>";
} else {
	echo "文章写入失败<br>" . mysqli_error() . "<br>";
}



